package [path_1].[path_2].manager.controller.[path_3];

import [path_1].[path_2].entity.PageResult;
import [path_1].[path_2].entity.Result;
import [path_1].[path_2].pojo.[path_3].[Table2];
import [path_1].[path_2].dto.[path_3].[Table2]Dto;
import [path_1].[path_2].service.[path_3].[Table2]Service;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/api/v1/[table2]s")
public class [Table2]Controller {

    @Reference
    private [Table2]Service [table2]Service;

    @GetMapping
    public List<[Table2]> get[Table2]All(){
        return [table2]Service.get[Table2]All();
    }

    @GetMapping("/list")
    public PageResult get[Table2]List([Table2]Dto dto){
        return [table2]Service.get[Table2]List(dto);
    }

    @GetMapping("/{id}")
    public [Table2] get[Table2]ById(@PathVariable("id")[keyType] [key2]){
        return [table2]Service.get[Table2]ById([key2]);
    }

    @PostMapping
    public Result save[Table2](@RequestBody [Table2]Dto dto){
        [table2]Service.save[Table2](dto);
        return new Result();
    }

    @PutMapping("{id}")
    public Result update[Table2](@PathVariable("id") [keyType] [key2], @RequestBody [Table2]Dto dto){
		dto.set[Key2]([key2]);
        [table2]Service.update[Table2](dto);
        return new Result();
    }

    @DeleteMapping("{id}")
    public Result delete[Table2]ById(@PathVariable("id") [keyType] [key2]){
        [table2]Service.delete[Table2]ById([key2]);
        return new Result();
    }

}
